<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-UK" lang="en-UK">
<head>
<title><%= Settings.short_title %> | <%= @page_title || "Administration" %></title>	

<%= javascript_include_tag :defaults, :cache => true %>
<%= javascript_include_tag :fckeditor %>

<!-- Stylesheets -->
<%= stylesheet_link_tag 'admin_base', :media => "all" %>

<% if flash[:notice] -%>
   <%= javascript_tag "window.onload = function(){#{visual_effect :appear, "notice", :duration => 0.75}}" %>
<% end %>
	
</head>
<body>

   <div id="header">
      <h1><%= Settings.short_title %> Website Administration
         <span>
            <%= link_to "Logout", { :controller => "/account", :action => "logout" }, { :class => "logout" } %>
         </span>
      </h1>
   </div>

   <ul id="adminmenu">
      
      <!-- Insert the dashboard link -->
      <li <%= "class='current'" if @controller.controller_name == "dashboard" %>><%= link_to "Dashboard", {:controller => "admin/dashboard"}, {:class => "dashboard"}  %></li>
      
      <!-- links that get built based on user permissions, add new links to the array -->
      
      <% menu_items = Array.new -%>
      <% menu_items << {:text => 'Users', :controller => 'users', :role => 'users'} -%>
      <% menu_items << {:text => 'Announcements', :controller => 'announcements', :role => 'announcements'} -%>
      <% menu_items << {:text => 'Pages', :controller => 'pages', :role => 'pages'} -%>
      <% menu_items << {:text => 'Tags', :controller => 'tags', :role => 'tags'} -%>
      <% menu_items << {:text => 'Podcasts', :controller => 'podcasts', :role => 'podcast'} -%>
      <% menu_items << {:text => 'Videos', :controller => 'videos', :role => 'videos'} -%>
      <% menu_items << {:text => 'Photos', :controller => 'albums', :role => 'photos'} -%>
      <% menu_items << {:text => 'Housing Application', :controller => 'app_questions', :role => 'app_questions'} -%>
      <% menu_items << {:text => 'Settings', :controller => 'settings', :role => 'settings'} -%>
      
      <% menu_items.each do |menu_item| -%>
         <% restrict_to "admin | #{menu_item[:role]}" do -%>
            <li <%= "class='current'" if @controller.controller_name == menu_item[:controller] %>><%= link_to menu_item[:text], {:controller => "admin/#{menu_item[:controller]}"}, {:class => menu_item[:controller]}  %></li>
         <% end -%>
      <% end -%>
      
      <!-- Insert the profile link -->
      <li <%= "class='current'" if @controller.controller_name == "profile" %>><%= link_to "Profile", {:controller => "admin/profile"}, {:class => "profile"}  %></li>
   </ul>

   <div class="wrap">
      <%= yield :layout %>
   </div>
   
   <div id="footer">
      <p>Developed by <%= mail_to "monroe.josh@gmail.com", "Josh Monroe", :encode => "javascript" %> and coded with <%= link_to "Ruby on Rails", "http://www.rubyonrails.org" %></p>
   </div>
   
   <% if flash[:notice] -%>
   <div id="notice" class="alert" style="display:none;" onclick='<%= visual_effect :fade, "notice", :duration => 0.75 %>'>
      <%= flash[:notice] %>
   </div>
   <% end -%>
   
</body>
</html>